#include "SphereDialog.h"
#include "../math/Vec3.h"

SphereDialog::SphereDialog( wxWindow* parent )
:
Sphere_Dialog_Base( parent )
{

}


bool SphereDialog::TransferDataFromWindow()
{
    Vec3 centre;
    double radius;
    double value;
    double aux;

    x_textCtrl->GetValue().ToDouble(&aux);
    centre.x = aux;
    y_textCtrl->GetValue().ToDouble(&aux);
    centre.y = aux;
    z_textCtrl->GetValue().ToDouble(&aux);
    centre.z = aux;

    radius_textCtrl->GetValue().ToDouble(&radius);
    value_textCtrl->GetValue().ToDouble(&value);

    sphere = new Sphere(centre, radius, value);

    return true;
}


void SphereDialog::onOK( wxCommandEvent& event )
{
    if ( Validate() && TransferDataFromWindow() )
    {
        if ( IsModal() )
             EndModal(wxID_OK); // If modal
        else
        {
             SetReturnCode(wxID_OK);
             this->Show(false); // If modeless
        }
    }
}


Sphere* SphereDialog::getSphere()
{
	return sphere;
}
